//
//  MoreViewController.m
//  homeland
//
//  Created by rain on 14-5-26.
//  Copyright (c) 2014年 xzysun. All rights reserved.
//

#import "MoreViewController.h"
#import "WebViewController.h"
#import "HelpListCell.h"

@interface MoreViewController ()

@end

@implementation MoreViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"更多";
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationItem.leftBarButtonItem = nil;
}

//tab改变
#pragma mark - Table Methods
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
//设置item数量
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44.0f;
}

//设置值
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell;
        //登录状态下的第4个或者非登录状态下的第3个为帮助
        cell = [[[NSBundle mainBundle]loadNibNamed:@"HelpListCell" owner:self options:nil]objectAtIndex:0];
        if (indexPath.row == 0) {
            ((HelpListCell *)cell).titleLabel.text = @"帮助";
            ((HelpListCell *)cell).flagImageView.hidden = YES;
            ((HelpListCell *)cell).indImageView.hidden = NO;
        }
        else if (indexPath.row == 1) {
            ((HelpListCell *)cell).titleLabel.text = @"关于";
            ((HelpListCell *)cell).flagImageView.hidden = YES;
            ((HelpListCell *)cell).indImageView.hidden = NO;

        } else if(indexPath.row == 2) {
            ((HelpListCell *)cell).titleLabel.text = @"分享";
            ((HelpListCell *)cell).flagImageView.hidden = YES;
            ((HelpListCell *)cell).indImageView.hidden = NO;

        }
//        else if(indexPath.row == 3) {
//            ((HelpListCell *)cell).titleLabel.text = @"更新";
//            ((HelpListCell *)cell).flagImageView.hidden = YES;
//            ((HelpListCell *)cell).indImageView.hidden = NO;
//
//        }
        else if(indexPath.row == 3) {
            ((HelpListCell *)cell).titleLabel.text = @"通知提醒";
            ((HelpListCell *)cell).flagImageView.hidden = YES;
            ((HelpListCell *)cell).indImageView.hidden = YES;
            ((HelpListCell *)cell).switchCtr.hidden = NO;
        } else {
            ((HelpListCell *)cell).titleLabel.text = @"绑定手机";
            ((HelpListCell *)cell).flagImageView.hidden = YES;
            ((HelpListCell *)cell).indImageView.hidden = NO;

        }
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.accessoryType = UITableViewCellAccessoryNone;

    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
        //登录状态下的第4个或者非登录状态下的第2个为帮助
    if (indexPath.row == 0) {
        //跳转 登录页面
//            [self login];
    }
    if (indexPath.row == 0) {
        //跳转 帮助页面
        [self showWebView:@"Help"];
    } else if(indexPath.row == 1) {
        //跳转 关于页面
        [self showWebView:@"About"];
    } else if(indexPath.row == 3) {

    }

    return;
}

#pragma mark - Show WebView
-(void)showWebView:(NSString *)key
{
    NSString *url;
    NSString *title;
    if ([key isEqualToString:@"About"]) {
        url = @"about";
        title = @"关于";
    } else if ([key isEqualToString:@"Help"]) {
        url = @"help";
        title =@"帮助";
    }
    if (url && url.length > 0) {
        WebViewController *webVC = [[WebViewController alloc]initWithNibName:@"WebViewController" bundle:nil];
        //        webVC.url = url;
        webVC.title = title;
        webVC.name = url;
        webVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:webVC animated:YES];
        //        [webVC loadFileWithName:url];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
